<?php

use yii\grid\GridView;
use yii\widgets\ActiveForm;
use \app\models\Supplier;
use \yii\helpers\Html;


$form = ActiveForm::begin([
    'id' => 'supplier-form',
    'method' => 'get',
    'action' => \yii\helpers\Url::to(['site/grid-view']),
    'options' => [
        'class' => 'row'
    ],
    'fieldConfig' => [
        'template' => '<div class="col">{label}{input}{error}</div>'
    ],
]);

?>

<?php
$supplierModel = new Supplier();

echo $form->field($supplierModel, 'id')->textInput([
    'name' => 'id',
    'style' => 'min-width:200px',
    'value' => Yii::$app->request->get('id')
])->label('主键ID');

echo $form->field($supplierModel, 'name')->textInput([
    'name' => 'name',
    'style' => 'min-width:200px',
    'value' => Yii::$app->request->get('name')
])->label('名称Name');

echo $form->field($supplierModel, 'code')->textInput([
    'name' => 'code',
    'style' => 'min-width:200px',
    'value' => Yii::$app->request->get('code')
])->label('代码Code');

echo $form->field($supplierModel, 't_status')->dropDownList([
    '' => '全部',
    'ok' => 'ok',
    'hold' => 'hold'
], [
    'name' => 't_status',
    'style' => 'min-width:200px',
    'value' => Yii::$app->request->get('t_status')
])->label('状态Status');
?>
<div class="col-md-12">
    <?= Html::resetButton('重置', ['class' => 'btn btn-secondary', 'id' => 'reset-form', 'name' => 'search-button']) ?>
    <?= Html::submitButton('搜索', ['class' => 'btn btn-primary', 'name' => 'search-button']) ?>
    <?= Html::a('导出全部', \yii\helpers\Url::to(['export',
        'id' => Yii::$app->request->get('id'),
        'name' => Yii::$app->request->get('name'),
        'code' => Yii::$app->request->get('code'),
        't_status' => Yii::$app->request->get('t_status'),
        'total' => $total
    ]), ['class' => 'btn btn-success']) ?>
</div>

<?php ActiveForm::end(); ?>

<br>
<?= GridView::widget([
    'dataProvider' => $datas,
    'layout' => '{items} <nav aria-label="Page navigation">{pager}</nav>',

    'pager' => [
        'options' => [
            'class' => 'pagination'
        ],
        'prevPageLabel' => '上一页',
        'nextPageLabel' => '下一页',
        'prevPageCssClass' => 'page-item',
        'pageCssClass' => 'page-item',
        'nextPageCssClass' => 'page-item',
        'disabledPageCssClass' => 'page-link',
        'activePageCssClass' => 'active',
        'linkOptions' => [
                'class' => 'page-link',
        ]
    ],
    'columns' => [
        [
            'class' => \yii\grid\CheckboxColumn::class
        ],
        [
            'label' => '主键ID',
            'attribute' => 'id',
            'format' => 'text',
        ],
        [
            'label' => '名称Name',
            'attribute' => 'name',
            'format' => 'text',
        ],
        [
            'label' => '代码Code',
            'attribute' => 'code',
            'format' => 'text',
        ],
        [
            'label' => '状态Status',
            'attribute' => 't_status',
            'format' => 'text',
        ],
    ],
]);
?>